<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('blinds', function (Blueprint $table) {
            $table->id();
            $table->string('name')->comment('盲盒名称');
            $table->string('description')->nullable()->comment('盲盒描述');
            $table->string('url')->nullable()->comment('盲盒图片');
            $table->decimal('price', 10, 2)->comment('盲盒价格');
            $table->unsignedInteger('stock_quantity')->default(0)->comment('盲盒库存');
            $table->foreignId('admin_id')->constrained()->onDelete('cascade');
            $table->foreignId('blind_cate_id')->constrained('blind_cates', 'id', 'blind_cate_id')->onDelete('cascade')->comment('盲盒分类ID');
            $table->unsignedInteger('order')->default(0)->comment('排序');
            $table->tinyInteger('hidden')->default(1)->comment('0:false/1:true');
            $table->string('status')->default('1')->comment('盲盒状态');
            $table->string('reason',1000)->nullable()->comment('驳回原因');
            $table->string('blind_type')->default('1')->comment('盲盒类型');  // 正常抽 拼团抽
            $table->string('type')->nullable()->default('1')->comment('抽奖类型');
            $table->timestamp('tend_time')->nullable()->comment('拼团结束时间'); // 拼团类型用到
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('blinds');
    }
};
